<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/cms/include/init_admin.jsp" %>
<%@ page import="com.qbooks.cms.product.*" %>
<%

	HashList codeUseYn	= CommonUtil.getCodeList("use_yn");
	HashList code013	= CommonUtil.getCodeList("013");

	HashMap infos = new HashMap();


	ProductDAO dao 	= new ProductDAO();
	HashList list 	= dao.selectCategoryList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/cms/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {

	
		$('#list').find('input, select').change(function() {
			$(this).closest('tr').find('input[name="list.job_type"]').val('U');
		});
		
		$("#chkAll").click(function(){
			cfCheckAll();
		});
	});

	function fnSave() {
		$("#saveForm").attr('action', './categorySave.do');
		$("#saveForm").submit();
	}


	function fnAddRow() {
		var txt = '<tr><td><input type="checkbox" name="chk" />'
				+ '<input type="hidden" name="list.job_type" value="C" /></td>'
				+ '<td><input type="text" name="list.category_code" value="" class="wmax"/></td>'
				+ '<td><select name="list.category_group"><%= StringUtil.makeOption(code013, "") %></select></td>'
				+ '<td><input type="text" name="list.category_name" value="" class="wmax"/></td>'
				+ '<td><input type="text" name="list.image_url" value="" class="wmax"/></td>'
				+ '<td><input type="text" name="list.sort" value="" class="wmax"/></td>'
				+ '<td><select name="list.use_yn"><%= StringUtil.makeOption(codeUseYn, "") %></select></td>'
				+ '<td></td>'
				+ '<td></td></tr>';

		$("#list").append(txt);
	}

	function fnDeleteRow() {
		var chks = $('input:checkbox[name="chk"]:checked');
		for (var i = 0; i < chks.length; i++) {
			$(chks[i]).closest('tr').find('input[name="list.job_type"]').val('D');
			$(chks[i]).closest('tr').hide();
		}
	}
	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/cms/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/cms/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>카테고리</h1>
				<p>CMS > 상품관리 > <b>카테고리</b></p>
			</div>
			<div class="clear line_01"></div>

			

			<div class="search_result">검색결과 : <%= list.size() %>건</div>


			<form id="saveForm" method="post" action="./categorySave.do">
				
		    <table cellpadding="0" cellspacing="0" class="table_03">
				<colgroup>
					<col width="30px"/>
					<col width="60px"/>
					<col width="100px"/>
					<col width="200px"/>
					<col width="300px"/>
					<col width="100px"/>
					<col width="100px"/>
					<col width="100px"/>
					<col />
				</colgroup>
				<thead>
					<tr>
						<th><p><input type="checkbox" name="chkAll" id="chkAll"/></p></th>
						<th><p>코드</p></th>
						<th><p>분야</p></th>
						<th><p>카테고리명</p></th>
						<th><p>이미지경로</p></th>
						<th><p>정렬</p></th>
						<th><p>사용여부</p></th>
						<th><p>최종수정일</p></th>
						<th><p></p></th>
					</tr>
				</thead>
				<tbody id="list">
			<%	for (int i = 0; i < list.size(); i++) { %>
					<tr>
						<td>
							<input type="checkbox" name="chk" />
							<input type="hidden" name="list.job_type" value="X" />
							<input type="hidden" name="list.category_code" value="<%= list.get("category_code", i) %>"/>
						</td>
						<td><%= list.get("category_code", i) %></td>
						<td>
							<select name="list.category_group">
							<%= StringUtil.makeOption(code013, list.get("category_group", i)) %>
							</select>
						</td>
						</td>
						<td><input type="text" name="list.category_name" value="<%= list.get("category_name", i) %>" class="wmax"/></td>
						<td><input type="text" name="list.image_url" value="<%= list.get("image_url", i) %>" class="wmax"/></td>
						<td><input type="text" name="list.sort" value="<%= list.get("sort", i) %>" class="wmax"/></td>
						<td>
							<select name="list.use_yn">
							<%= StringUtil.makeOption(codeUseYn, list.get("use_yn", i)) %>
							</select>
						</td>
						<td><%= list.get("up_date", i) %></td>
						<td></td>
					</tr>
			<%	} %>
				</tbody>
			</table>
			
			<div class="mt20 mb10 c">
				<img src="../images/btn_addrow.gif" style="cursor:hand" onclick="fnAddRow()"/>
				<img src="../images/btn_delrow.gif" style="cursor:hand" onclick="fnDeleteRow()"/>
				<input type="image" class="button" src="../images/btn_save.gif" />
			</div>
			
			</form>

		</div>
	</div>
</div>
</body>
</html>
